package com.topdt.jbpm.web.servlet.action;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DBstep.iDBManager2000;

import com.thx.common.spring.BeanFactory;
import com.thx.common.util.AppContext;
import com.thx.common.util.ObjectUtils;
import com.thx.common.util.StringUtil;
import com.thx.common.web.SessionInfo;
import com.thx.common.web.WebConstant;
import com.topdt.jbpm.form.Document;
import com.topdt.jbpm.form.FormHandle;
import com.topdt.jbpm.form.FormMenuDefin;
import com.topdt.jbpm.model.Application;
import com.topdt.jbpm.model.Control;
import com.topdt.jbpm.model.Form;
import com.topdt.jbpm.model.Todo;
import com.topdt.jbpm.model.Work;
import com.topdt.jbpm.service.ApplicationService;
import com.topdt.jbpm.service.ControlService;
import com.topdt.jbpm.service.WorkService;
import com.topdt.jbpm.utils.SearchDocument;
import com.topdt.jbpm.web.servlet.JbpmServlet;

/**
 *
 * 建立日期 : 2013-9-18 上午11:37:34<br>
 * 作者 : 石艳<br>
 * 模块 : <br>
 * 描述 : 公文正文的action<br>
 * 修改历史: 序号 日期 修改人 修改原因 <br>
 * 1 <br>
 * 2 <br>
 */
public class DocumentAction extends JbpmBaseAction {

  public DocumentAction(JbpmServlet servlet) {
    super(servlet);
  }

	/**
	 * 表单页面编辑正文	
	 * @author zhangyong
	 * @date   2016年12月7日 下午2:42:53 
	 * @param request
	 * @param response
	 */
	public void editDoc(HttpServletRequest request, HttpServletResponse response){
		String workId = request.getParameter("workId");
		String appId = request.getParameter("appId");
		String todoId = request.getParameter("todoId");
		String comId = AppContext.getCurrentComId();
		String docControl= "";
		
		String mFileName = null;
		String mFileDate = null;
	   //--套红盖章状态
	    int isInsert=0;
		//自动获取OfficeServer和OCX文件完整URL路径
		String mHttpUrlName = request.getRequestURI();
		String mScriptName = request.getServletPath();
		String mServerName="workflow/webOffice/OfficeServer.jsp";
		String mClientName="workflow/webOffice/iWebOffice2009_qixianzhengfu.cab#version=10,8,5,2";
		String mServerUrl = "http://"+ request.getServerName()+ ":"	+ request.getServerPort()	+ mHttpUrlName.substring(0, mHttpUrlName.lastIndexOf(mScriptName)) + "/" + mServerName;//取得OfficeServer文件的完整URL
		String mClientUrl="http://"+request.getServerName()+":"+request.getServerPort()+mHttpUrlName.substring(0,mHttpUrlName.lastIndexOf(mScriptName))+"/"+mClientName;
		String mHttpUrl = "http://"	+ request.getServerName()+ ":"+ request.getServerPort()	+ mHttpUrlName.substring(0, mHttpUrlName.lastIndexOf(mScriptName)) + "/";
		//request.setCharacterEncoding("utf-8");
		String mRecordID = request.getParameter("RecordID");
		String mFileType = request.getParameter("FileType");
		String mEditType = request.getParameter("EditType");
		String ShowMenu = request.getParameter("ShowMenu");//是否显示菜单	
		String ShowToolBar = request.getParameter("ShowToolBar");//是否显示工具栏	
//	 	说明：	false:	自定义工具栏=false,	Office工具栏=true;
//	 	true :	自定义工具栏=true,	Office工具栏=true;
//	 	    	0	:	自定义工具栏=false, 	Office工具栏=true;
//	 	    	1	:	自定义工具栏=true,	Office工具栏=true;
//	 	    	2	:	自定义工具栏=false, 	Office工具栏=false;
//	 	    	3	:	自定义工具栏=true,	Office工具栏=false;
		
		SessionInfo sessionInfo = (SessionInfo)request.getSession().getAttribute(WebConstant.KEY_USER);
		String mUserName = sessionInfo.getRealName();
		Application app = getAppByAppId(appId);
		
		WorkService workService = (WorkService)BeanFactory.getBean("workService");
		//获取权限控制对象
		ControlService controlService = (ControlService) BeanFactory.getBean("controlService");
		Work work = workService.getByWorkId(workId);
		//取公文操作权限start
		Form form = app.getForm();
		Todo todo=this.jbpmService.getTodoById(todoId);
		String activityName=todo.getActivityName();
		Object[] objs = new Object[] { app.getAppId(), work.getFlowId(), activityName, form.getFormId() };
		Control control = controlService.getControlByObjects(objs);
		String[][] menuItems = FormMenuDefin.getMenuItems(app.getAppAttr());
		for (int i = 0; i < menuItems.length; i++) {
			String[] item = menuItems[i];
			//weboffice编辑文档的按钮控制
			if(item[1].equals("编辑正文")) {
				docControl= control.getFunctionControl().substring(i);
				break;
			}			
		}
		if(docControl.equals("")){
			docControl="000";
		}
		//取公文操作权限end
		String flag = docControl;
		String bflag = String.valueOf(flag.charAt(0));
		String qflag = String.valueOf(flag.charAt(1));
		String mflag = String.valueOf(flag.charAt(2));
		// 取得编号
		if (mRecordID == null) {
			mRecordID = ""; // 编号为空
		}
		// 取得模式
		if (StringUtil.isBlank(mEditType) ) {
			mEditType = "2,1"; // x,y---x: 0 显示 1 起草 2 批改 3 审核;y:0不可手写批注,1可以手写批注
		}
		// 取得类型
		if (StringUtil.isBlank(mFileType) ) {
			mFileType = ".doc"; // 默认为.doc文档
		}
		// 取得用户名
		if (StringUtil.isBlank(mUserName)  ) {
			mUserName = "清众";
		}
		// 取得菜单显示设置
		if (ShowMenu == null) {
			ShowMenu = "0"; // 默认不显示
		}
		// 取得工具栏显示设置
		if (ShowToolBar == null) {
			ShowToolBar = "0"; // 默认不显示
		}
		String mTemplate= app.getDocTempath();
		String title =  this.getWorkTitle(workId);
		//打开数据库
		DBstep.iDBManager2000 DbaObj = new DBstep.iDBManager2000();
		if (DbaObj.OpenConnection()) {
			try {							
				//取得文件基本信息start
				String mSql = "Select * From Arc_Document Where WorkId='"+ workId + "'";
				ResultSet result =   DbaObj.ExecuteQuery(mSql);
				if (result.next()) {
					mRecordID = result.getString("RecordID");					
					mFileDate = result.getString("FileDate");
					mFileType = result.getString("FileType");
				} else {
					//取得唯一值(mRecordID)
					java.util.Date dt = new java.util.Date();
					long lg = dt.getTime();
					Long ld = new Long(lg);
					//初始化值
					mRecordID = ld.toString();//保存的是文档的编号，通过该编号，可以在里找到所有属于这条纪录的文档					
					mFileDate = DbaObj.GetDateTime();
				}
				result.close();
				//取得文件基本信息end
				
				//查询文件盖章套红情况start
				String insertStr=null;
				String docSql = "Select * From Arc_Document Where RecordID='"+mRecordID + "'";
				ResultSet docResult = DbaObj.ExecuteQuery(docSql);
				if (docResult.next()) {
					insertStr = docResult.getString("IsInsert");
				}
				isInsert = Integer.valueOf(insertStr==null?"0":insertStr).intValue();
				docResult.close();
				//查询文件盖章套红情况end
			}catch (SQLException e) {
				logger.error(e.toString());
			}
			DbaObj.CloseConnection();
		}
		mFileName = mRecordID + mFileType; //取得完整的文档名称
		request.setAttribute("docControl", docControl);
		request.setAttribute("workId", workId);
		request.setAttribute("appId", appId);		
		request.setAttribute("mServerUrl", mServerUrl);
		request.setAttribute("mRecordID", mRecordID);
		request.setAttribute("mFileName", mFileName);
		request.setAttribute("mTemplate", mTemplate);
		request.setAttribute("mFileType", mFileType);
		request.setAttribute("mEditType", mEditType);
		request.setAttribute("mUserName", mUserName);
		request.setAttribute("mFileDate", mFileDate);
		request.setAttribute("ShowMenu", ShowMenu);
		request.setAttribute("ShowToolBar", ShowToolBar);
		request.setAttribute("mClientUrl", mClientUrl);
		request.setAttribute("comId", comId);
		request.setAttribute("mHttpUrl", mHttpUrl);
		request.setAttribute("title", title);
		request.setAttribute("isInsert", isInsert);
		request.setAttribute("flag",flag);
		request.setAttribute("bflag",bflag);
		request.setAttribute("qflag",qflag); 
		request.setAttribute("mflag",mflag); 
		responseJsp(request, response, "/workflow/webOffice/editDoc.jsp");
	}
	/**
	 * 公文正文打印
	 * @author zhangyong
	 * @date   2016年12月15日 下午3:32:58 
	 * @param request
	 * @param response
	 */
	public void printDoc(HttpServletRequest request, HttpServletResponse response){
		String workId = request.getParameter("workId");
		String appId = request.getParameter("appId");
		String comId = AppContext.getCurrentComId();
		String docControl= "000";
		
	   //--套红盖章状态
	    int isInsert=0;
		//自动获取OfficeServer和OCX文件完整URL路径
		String mHttpUrlName = request.getRequestURI();
		String mScriptName = request.getServletPath();
		String mServerName="workflow/webOffice/OfficeServer.jsp";
		String mClientName="workflow/webOffice/iWebOffice2009_qixianzhengfu.cab#version=10,8,5,2";
		String mServerUrl = "http://"+ request.getServerName()+ ":"	+ request.getServerPort()	+ mHttpUrlName.substring(0, mHttpUrlName.lastIndexOf(mScriptName)) + "/" + mServerName;//取得OfficeServer文件的完整URL
		String mClientUrl="http://"+request.getServerName()+":"+request.getServerPort()+mHttpUrlName.substring(0,mHttpUrlName.lastIndexOf(mScriptName))+"/"+mClientName;
		String mHttpUrl = "http://"	+ request.getServerName()+ ":"+ request.getServerPort()	+ mHttpUrlName.substring(0, mHttpUrlName.lastIndexOf(mScriptName)) + "/";
		//request.setCharacterEncoding("utf-8");
		String mRecordID = "";
		String mFileType = "";
		String mEditType = "1,1"; // x,y---x: 0 显示 1 起草 2 批改 3 审核;y:0不可手写批注,1可以手写批注
		String ShowMenu = request.getParameter("ShowMenu");//是否显示菜单	
		String ShowToolBar = "2";//是否显示工具栏	
//	 	说明：	false:	自定义工具栏=false,	Office工具栏=true;
//	 	true :	自定义工具栏=true,	Office工具栏=true;
//	 	    	0	:	自定义工具栏=false, 	Office工具栏=true;
//	 	    	1	:	自定义工具栏=true,	Office工具栏=true;
//	 	    	2	:	自定义工具栏=false, 	Office工具栏=false;
//	 	    	3	:	自定义工具栏=true,	Office工具栏=false;
		
		SessionInfo sessionInfo = (SessionInfo)request.getSession().getAttribute(WebConstant.KEY_USER);
		Application app = getAppByAppId(appId);
		
		String flag = docControl;
		String bflag = String.valueOf(flag.charAt(0));
		String qflag = String.valueOf(flag.charAt(1));
		String mflag = String.valueOf(flag.charAt(2));
		// 取得编号
		if (mRecordID == null) {
			mRecordID = ""; // 编号为空
		}
		// 取得类型
		if (StringUtil.isBlank(mFileType) ) {
			mFileType = ".doc"; // 默认为.doc文档
		}
		// 取得菜单显示设置
		if (ShowMenu == null) {
			ShowMenu = "0"; // 默认不显示
		}
		String title =  this.getWorkTitle(workId);
		//打开数据库
		DBstep.iDBManager2000 DbaObj = new DBstep.iDBManager2000();
		if (DbaObj.OpenConnection()) {
			try {							
				//取得文件基本信息start
				String mSql = "Select * From Arc_Document Where WorkId='"+ workId + "'";
				ResultSet result =   DbaObj.ExecuteQuery(mSql);
				if (result.next()) {
					mRecordID = result.getString("RecordID");					
					mFileType = result.getString("FileType");
				} else {
					//取得唯一值(mRecordID)
					java.util.Date dt = new java.util.Date();
					long lg = dt.getTime();
					Long ld = new Long(lg);
					//初始化值
					mRecordID = ld.toString();//保存的是文档的编号，通过该编号，可以在里找到所有属于这条纪录的文档					
				}
				result.close();
				//取得文件基本信息end
				
			}catch (SQLException e) {
				logger.error(e.toString());
			}
			DbaObj.CloseConnection();
		}
		request.setAttribute("docControl", docControl);
		request.setAttribute("workId", workId);
		request.setAttribute("appId", appId);		
		request.setAttribute("mServerUrl", mServerUrl);
		request.setAttribute("mRecordID", mRecordID);
		request.setAttribute("mFileType", mFileType);
		request.setAttribute("mEditType", mEditType);
		request.setAttribute("ShowMenu", ShowMenu);
		request.setAttribute("ShowToolBar", ShowToolBar);
		request.setAttribute("mClientUrl", mClientUrl);
		request.setAttribute("comId", comId);
		request.setAttribute("mHttpUrl", mHttpUrl);
		request.setAttribute("title", title);
		request.setAttribute("isInsert", isInsert);
		request.setAttribute("flag",flag);
		request.setAttribute("bflag",bflag);
		request.setAttribute("qflag",qflag); 
		request.setAttribute("mflag",mflag); 
		responseJsp(request, response, "/workflow/webOffice/editDoc.jsp");		
	}
	
	/**
	 * 保存文档
	 * @author zhangyong
	 * @date   2016年12月14日 下午5:35:14 
	 * @param request
	 * @param response
	 */
	public void save(HttpServletRequest request, HttpServletResponse response){
		logger.debug("开始保存文档");
		String mRecordID=request.getParameter("RecordID");
		if (mRecordID==null) mRecordID="";
		String mTemplate=new String(request.getParameter("Template"));
		String mSubject=new String(request.getParameter("Subject"));
		String mAuthor=new String(request.getParameter("Author"));
		String mFileType=new String(request.getParameter("FileType"));
		String mHTMLPath=new String(request.getParameter("HTMLPath"));
		String workId =new String(request.getParameter("workId"));
		int mDocumentId = 0;
		DBstep.iDBManager2000 DbaObj = new DBstep.iDBManager2000();
		if (DbaObj.OpenConnection()) {
			String mysql = "SELECT DocumentID,RecordID from ARC_DOCUMENT Where RecordID='"	+ mRecordID + "'";
			// String mFileDate=DbaObj.GetDateTime() ;
			try {
				ResultSet result = DbaObj.ExecuteQuery(mysql);
				if (result.next()) {
					mysql = "update Arc_Document set DocumentID=?,RecordID=?,Template=?,Subject=?,Author=?,FileDate=?,FileType=?,HtmlPath=?,Status=?,WorkID=? where RecordID='"
							+ mRecordID + "'";
					mDocumentId = result.getInt("DocumentID");
				} else {
					mDocumentId = DbaObj.GetMaxID("Arc_Document", "DocumentID");
					mysql = "insert into Arc_Document (DocumentID,RecordID,Template,Subject,Author,FileDate,FileType,HtmlPath,Status,WorkID) values (?,?,?,?,?,?,?,?,?,?)";
				}
				result.close();
			} catch (Exception e) {
				logger.error("",e);
				responseJson(response, "保存失败");
			}
			java.sql.PreparedStatement prestmt = null;
			try {
				DbaObj.OpenConnection();
				prestmt = DbaObj.Conn.prepareStatement(mysql);
				prestmt.setInt(1, mDocumentId);
				prestmt.setString(2, mRecordID);
				prestmt.setString(3, mTemplate);
				prestmt.setString(4, mSubject);
				prestmt.setString(5, mAuthor);
				prestmt.setDate(6, DbaObj.GetDate());
				prestmt.setString(7, mFileType);
				prestmt.setString(8, mHTMLPath);
				prestmt.setString(9, "READ");
				prestmt.setString(10, workId);
				// DbaObj.Conn.setAutoCommit(true) ;
				prestmt.executeUpdate();
				// DbaObj.Conn.commit();

			} catch (Exception e) {
				logger.error("",e);
				responseJson(response, "保存失败");
			} finally {
				try {
					prestmt.close();
				} catch (SQLException e) {
					logger.error("",e);
				}
			}
			DbaObj.CloseConnection();
		} else {
			logger.error("OpenDatabase Error");
			responseJson(response, "保存失败");
		}
	
		responseJson(response, "保存成功");
	}
	/**
	 * 得到标签和标签数据的map
	 * @author zhangyong
	 * @date   2016年12月8日 下午4:41:22 
	 * @param request
	 * @param response
	 */
	public void getMapOfBookMarksAndDataMarks(HttpServletRequest request, HttpServletResponse response){
		Map<String, String[]> map = new HashMap<String, String[]>();
		String mTemplate = request.getParameter("mTemplate");
		String workId = request.getParameter("workId");
		String appId = request.getParameter("appId");
		Application app = getAppByAppId(appId);
		String[] bookMarks = this.getBookMarks(mTemplate);
		String[] dataMarks = this.getDataMarks(app, workId, bookMarks.length, bookMarks);
		map.put("bookMarks", bookMarks);
		map.put("dataMarks", dataMarks);
		responseJson(response, map);
	}
	/**
	 * 得到标题
	 * @author zhangyong
	 * @date   2016年12月8日 下午4:32:56 
	 * @param workId
	 * @return
	 */
	private String getWorkTitle(String workId){
		WorkService workService = (WorkService)BeanFactory.getBean("workService");
		Work work = workService.getByWorkId(workId);
		String title="";
		if(work!=null){
			title = work.getWorkTitle();
			if(StringUtil.notBlank(title)){
				title=title.replaceAll("\r|\n", "");//去除换行
			}
		}else{
			title="请输入标题";
		}
		 return title;
	}
	
	
	/**
	 * 
	 * @author zhangyong
	 * @date   2016年12月8日 下午4:22:42 
	 * @param appId
	 * @return
	 */
	public Application getAppByAppId(String appId){
		ApplicationService applicationService = (ApplicationService)BeanFactory.getBean("applicationService");
		Application app = applicationService.findById(appId);
		return app;
	}

	
	
	/**
	 * 得到模板标签的数组
	 * @author zhangyong
	 * @date   2016年12月8日 下午4:10:52 
	 * @param mTemplate
	 * @return
	 */
	public String[] getBookMarks(String mTemplate){
		ResultSet bookResult = null;
		String[] bookMarks = new String[0];
		//打开数据库
		DBstep.iDBManager2000 DbaObj = new DBstep.iDBManager2000();
		if (DbaObj.OpenConnection()) {		
			try {
				String bookSql = "Select * From ARC_TEMPLATE_BOOKMARKS Where RECORDID='"+ mTemplate + "'";
				bookResult = DbaObj.ExecuteQuery(bookSql);
				List<String> list = new ArrayList<String>();
				while (bookResult.next()) {
					list.add(bookResult.getString("BOOKMARKNAME"));
				}
				if (list != null && list.size() > 0) {
					bookMarks = new String[list.size()];
					for (int i = 0; i < list.size(); i++) {
						bookMarks[i] = list.get(i).trim();
						logger.debug("标签：" + bookMarks[i]);
					}
				}
				bookResult.close();
			} catch (Exception e) {
				logger.error("<错误>：查询标签异常",e);
			}
			DbaObj.CloseConnection();
		}
		return bookMarks;
	}
	
	/**
	 * 得到标签对应的数据的数组
	 * @author zhangyong
	 * @date   2016年12月8日 下午4:14:41 
	 * @param app
	 * @param workId
	 * @param bookMarksLength
	 * @param bookMarks
	 * @return
	 */
	public String[] getDataMarks(Application app,String workId,int bookMarksLength,String[] bookMarks){
		/**
		 文档套稿的时候，获取表单的数据来替换文档的标签
		*/
		Object obj = ObjectUtils.getInstance(app.getHandle().getHandleJava());
		FormHandle formHandle = (FormHandle) obj;
		Document doc = formHandle.getDocument(workId);
		Map<String,Object>   data=doc.getDataMap();
		
		String[] dataMarks = new String[bookMarksLength];
		for (int i = 0; i < bookMarksLength; i++) {
			if (data != null) {
				dataMarks[i] = data.get(bookMarks[i])!=null?data.get(bookMarks[i]).toString():"";
				logger.debug("公文套稿数据：标签名："+bookMarks[i]+"标签值："+dataMarks[i]);
			}
		} 
		return dataMarks;
	}
	
	
  /**
   * 查询文章是否已套红或盖章
   */
  public void isInsertByWorkId(HttpServletRequest request, HttpServletResponse response)  {
		logger.debug("<进入>:isInsertByWorkId方法   查询文章是否已套红或盖章");
		String workId = request.getParameter("workId");
		iDBManager2000 DbaObj = new iDBManager2000();
		ResultSet docResult = null;
		int isInsert = 0;
		if (DbaObj.OpenConnection()) {
			String insertStr = null;
			String docSql = "Select * From Arc_Document Where workId='"	+ workId + "'";
			try {
				docResult = DbaObj.ExecuteQuery(docSql);
				if (docResult.next()) {
					insertStr = docResult.getString("IsInsert");
				}
				isInsert = Integer.valueOf(insertStr == null ? "0" : insertStr).intValue();
				docResult.close();
			} catch (SQLException e) {
				logger.error("<错误>: 查询文章是否已套红或盖章失败", e);
			} finally {
				DbaObj.CloseConnection();
			}
		}
		responseJson(response, isInsert);
  }


  /**
   * 更新文档的套稿状态
   *
   * @author 冯晋首
   * @date 2016年1月9日 下午7:24:40
   * @param request
   * @param response
   * @throws IOException
   */
  public void insertDocByWorkId(HttpServletRequest request, HttpServletResponse response)  {
		logger.debug("<进入>:insertDocByWorkId方法   更新文档的套稿状态");
		String workId = request.getParameter("workId");
		iDBManager2000 DbaObj = new iDBManager2000();
		String status = "success";
		if (DbaObj.OpenConnection()) {
			String docSql = "update  arc_document t  set t.isinsert='1' where t.workid='"+ workId + "'";
			try {
				DbaObj.ExecuteUpdate(docSql);
			} catch (Exception e) {
				logger.error("<错误>: 更新文档的套稿状态失败", e);
				status = "fail";
			}
		}
		responseJson(response, status);
  }


  /**
   * 更新文档的套稿签章状态
   *
   * @author 冯晋首
   * @date 2016年1月25日 上午9:24:40
   * @param request
   * @param response
   * @throws IOException
   */
  public void signDocByWorkId(HttpServletRequest request, HttpServletResponse response)  {
		logger.debug("<进入>:signDocByWorkId方法   更新文档的套稿签章状态");
		String workId = request.getParameter("workId");
		iDBManager2000 DbaObj = new iDBManager2000();
		String status = "success";
		if (DbaObj.OpenConnection()) {
			String docSql = "update  arc_document t  set t.isinsert='2' where t.workid='"+ workId + "'";
			try {
				DbaObj.ExecuteUpdate(docSql);
			} catch (Exception e) {
				logger.error("<错误>: 更新文档的套稿签章状态失败", e);
				status = "fail";
			}
		}
		responseJson(response, status);
  }

  /**
   * 查询是否已经编辑文档，针对有编辑文档的权限，如果没有编辑文档，不能提交
   *
   * @author zhangyong
   * @date 2016年1月7日 上午11:32:33
   * @param request
   * @param response
   * @throws IOException
   */
  public void isHaveDocByWorkId(HttpServletRequest request, HttpServletResponse response) {
		logger.debug("<进入>:isHaveDocByWorkId方法");
		String workId = request.getParameter("workId");
		iDBManager2000 DbaObj = new iDBManager2000();
		ResultSet docResult = null;
		int isHaveDoc = 0;
		if (DbaObj.OpenConnection()) {
			String docSql = "Select * From Arc_Document Where workId='"	+ workId + "'";
			try {
				docResult = DbaObj.ExecuteQuery(docSql);
				if (docResult.next()) {
					isHaveDoc = 1;
				}
				docResult.close();
			} catch (SQLException e) {
				logger.error("<错误>:查询是否已经编辑文档失败", e);
			} finally {
				DbaObj.CloseConnection();
			}
		}
		responseJson(response, isHaveDoc);
  }

  /**
  *
  * 建立日期 : Aug 26, 2013 10:39:13 AM<br>
  * 作者: 孙耀飞<br>
  * 模块: <br>
  * 描述: 查找公文正文的所有图片<br>
  * 1 fileType：文件类型；<br>
  * 2 folderPath：查找目录<br>
  */
	public void scanDocument(HttpServletRequest request,HttpServletResponse response)  {
		String folderPath = AppContext.getProperties("documentHtmlPath") + "/";
		folderPath += request.getParameter("folderPath");
		String fileType = request.getParameter("fileType");
		List<String> files = SearchDocument.scanDocument(folderPath, fileType);
		responseJson(response, files);
	}

}
